<?php


class PageNew{
 public $limit;
 public $total;
 public $length;
 public $page;
 public $pagenum;
 public $offset;
 public $prevpage;
 public $nextpage;
 function __construct($total,$length)
 {
	 //得到总行数
 	$this->total=$total;
 	//一页显示多少条
 	$this->length=$length;
 	//得到当前页，如果没有页码是第一页
 	$this->page =isset($_GET['p'])&&(!empty($_GET['p']))?$_GET['p']:1;
   //得到总页数
 	$this->pagenum=ceil($this->total/$this->length);
	 //计算limit后面offset值
 	$this->offset=($this->page-1)*$this->length;
 	$this->limit="limit {$this->offset},{$this->length}";


	 //计算上一页和下一页(需完善)
	 $this->prevpage=$this->page-1;
 	 $this->nextpage();
 }
 //计算下一页
 function nextpage(){
 	if($this->page < $this->pagenum){
 		{$this->nextpage=$this->page+1;}
	}else{
 		$this->nextpage = $this->pagenum;

 	}

 }
// function show(){
//	echo" <a href='indexs.php?p=1' target='_Self' >首页</a> |
//            <a href='indexs.php?p={$this->prevpage}'target='_Self' >上一页</a> |
//            <a href='indexs.php?p={ $this->nextpage}' target='_Self'>下一页</a> |
//            <a href='indexs.php?p={ $this->pagenum}' target='_Self'>末页</a>";
// }

}